package Chapter2.Comparing.c8;

import java.io.File;

public class Recursion1 {
    private  static int level;

    public static void main(String[] args) {
        File file = new File("E:\\users");
        displayFile(file);
    }

    private static void displayFile(File file) {
        level++;
        File[] files = file.listFiles();
        if(files==null){
            System.out.println("没有文件！！！");
            return;
        }
        for (File f:files) {
            String space="";
            for (int i=1;i<level;i++) {
                space= space + "*";
            }
            System.out.println(space + " " +f.getName());
            if(f.isDirectory()){
                displayFile(f);
            }
        }
        level--;
    }
}
